home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / scraction.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-12  |  6.8 KB  |  223 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7.  
  8. /***************************************************************************
  9.     begin                : Jan 2005
  10.     copyright            : (C) 2005 by Craig Bradney
  11.     email                : cbradney@zip.com.au
  12.  ***************************************************************************/
  13.  
  14. /***************************************************************************
  15.  *                                                                         *
  16.  *   This program is free software; you can redistribute it and/or modify  *
  17.  *   it under the terms of the GNU General Public License as published by  *
  18.  *   the Free Software Foundation; either version 2 of the License, or     *
  19.  *   (at your option) any later version.                                   *
  20.  *                                                                         *
  21.  ***************************************************************************/
  22. #ifndef SCRACTION_H
  23. #define SCRACTION_H
  24.  
  25. #include <QAction>
  26. #include <QPixmap>
  27. #include <QMenu>
  28. #include "scribusapi.h"
  29. class ScribusDoc;
  30. /**
  31. @author Craig Bradney
  32. */
  33. class SCRIBUS_API ScrAction : public QAction
  34. {
  35.     Q_OBJECT
  36.  
  37. public:
  38.     typedef enum {Normal, DataInt, DataDouble, DataQString, RecentFile, DLL, Window, RecentScript, UnicodeChar, Layer, ActionDLL, RecentPaste } ActionType;
  39.     
  40.     /*!
  41.         \author Craig Bradney
  42.         \date Jan 2005
  43.         \brief Constructor from QAction, sets menuType to Normal
  44.         \param parent Parent object of this action
  45.     */
  46.     ScrAction ( QObject *parent ) ;
  47.         
  48.     /*!
  49.         \author Craig Bradney
  50.         \date Jan 2005
  51.         \brief Constructor from QAction, sets menuType to normal
  52.         \param menuText Text to be in the menus for this action
  53.         \param accel Accelerator QKeySequence
  54.         \param parent Parent object of this action
  55.     */
  56.     ScrAction( const QString &menuText, QKeySequence accel, QObject *parent );
  57.         
  58.     /*!
  59.         \author Craig Bradney
  60.         \date Jan 2005
  61.         \brief Constructor for an action that may require a specific menu type, such as a DLL menu
  62.         \param mType menuType, of Normal, RecentFile or DLL
  63.         \param icon16 Iconset for the action
  64.         \param icon22 Iconset for the action
  65.         \param menuText Text to be in the menus for this action
  66.         \param accel Accelerator QKeySequence
  67.         \param parent Parent of this action
  68.         \param extraInt extra int value
  69.         \param extraDouble extra double value
  70.         \param extraQString extra QString value
  71.      */
  72.     ScrAction( ActionType mType, const QPixmap & icon16, const QPixmap & icon22,
  73.                const QString &menuText, QKeySequence accel, QObject *parent,
  74.                int extraInt = 0, double extraDouble = 0.0, QString extraQString = QString::null );        
  75.     /*!
  76.         \author Craig Bradney
  77.         \date Jan 2005
  78.         \brief Constructor for a normal action. Stores iconset.
  79.         \param icon Iconset for the action
  80.         \param menuText Text to be in the menus for this action
  81.         \param accel Accelerator QKeySequence
  82.         \param parent Parent of this action
  83.     */
  84.     ScrAction( const QPixmap & icon16, const QPixmap & icon22, const QString & menuText, QKeySequence accel, QObject *parent );
  85.     /*!
  86.     \author Craig Bradney
  87.     \date Mar 2008
  88.     \brief Constructor for a Unicode action.
  89.     \param accel Accelerator QKeySequence
  90.     \param parent Parent of this action
  91.     \param extraInt extra int value
  92.     \param extraQString extra QString value
  93.      */
  94.     ScrAction( QKeySequence accel, QObject *parent, int extraInt, QString extraQString);
  95.     ~ScrAction();
  96.     
  97.     /*!
  98.         \author Craig Bradney
  99.         \date Jan 2005
  100.         \brief Return the stored menuIndex as QActions cannot deal with these well
  101.         \retval int Index of menu the action was inserted into
  102.     */    
  103.     int getMenuIndex() const;
  104.             
  105.     /*!
  106.         \author Craig Bradney
  107.         \date Jan 2005
  108.         \brief Return a copy of the menu text, without the &s, possibility to remove ellipses in future.
  109.         \retval QString Stripped copy of the menu text
  110.     */
  111.     QString cleanMenuText();
  112.  
  113.     /*!
  114.         \author Craig Bradney
  115.         \date Jan 2005
  116.         \brief Return true if action is a DLL
  117.         \retval bool True if action is from a DLL
  118.      */
  119.     bool isDLLAction() const;
  120.     
  121.     /*!
  122.         \author Craig Bradney
  123.         \date Jan 2005
  124.         \brief Return DLL ID if the action is from a DLL, otherwise return -1
  125.         \retval int DLL ID or -1
  126.      */
  127.     int dllID() const;
  128.     
  129.     /*!
  130.      *    \author Craig Bradney
  131.      *    \date Feb 2005
  132.      *    \brief Connect the internal toggle connections. Fake toggle actions are toggle actions
  133.      *         but we connect activated() only, eg itemLock. This means they can be setOn()
  134.      *         to the status of an item's bool, eg isLocked(), without toggling anything.
  135.      */        
  136.     void setToggleAction(bool isToggle, bool fakeToggle=false);
  137.     
  138.     /*!
  139.         \author Craig Bradney
  140.         \date Feb 2005
  141.         \brief Store the shortcut in a private variable as these must be removed in editmode
  142.      */        
  143.     void saveShortcut();
  144.     /*!
  145.         \author Craig Bradney
  146.         \date Feb 2005
  147.         \brief Restore the saved shortcut to be the active one
  148.      */        
  149.     void restoreShortcut();    
  150.     /*!
  151.         \author Craig Bradney
  152.         \date Apr 2005
  153.         \brief Return the action data type
  154.      */        
  155.     ActionType actionType();
  156.     /*!
  157.         \author Craig Bradney
  158.         \date Apr 2005
  159.         \brief Return the action data of int action type
  160.      */        
  161.     int actionInt() const;
  162.     double actionDouble() const;
  163.     const QString actionQString();
  164.     void setActionQString(const QString &);
  165.     
  166.     /*! \brief Set up text and menuText at the same time */
  167.     void setTexts(const QString &newText, bool setTextToo = true);
  168.     
  169. public slots:
  170.     void toggle();
  171.     
  172. signals:
  173.     void triggeredData(int);
  174.     void triggeredData(double);
  175.     void triggeredData(QString);
  176.     void triggeredData(ScribusDoc*);
  177.     void toggledData(bool, int);
  178.     void toggledData(bool, double);
  179.     void toggledData(bool, QString);
  180.     void triggeredUnicodeShortcut(const QString&, int);
  181.     
  182. protected:
  183.     void initScrAction();
  184.     int menuIndex;
  185.     int pluginID;
  186.     int windowID;
  187.     int layerID;
  188.     int _dataInt;
  189.     double _dataDouble;
  190.     QString _dataQString;
  191.     ActionType _actionType;
  192.     QMenu *popupMenuAddedTo;
  193.     QKeySequence savedKeySequence;
  194.     bool shortcutSaved;
  195.     bool fakeToggle;
  196.     
  197.     /*!
  198.         \author Craig Bradney
  199.         \date Jan 2005
  200.         \brief Overridden addedTo QPopupmenu based function to save a pointer to the QPopupMenu we are adding to.
  201.         \param index The saved index within the QPopupMenu
  202.         \param menu The menu we are adding this action to
  203.     */
  204.     void addedTo( int index, QMenu * menu );
  205.                 
  206. private slots:
  207.     /*!
  208.         \author Craig Bradney
  209.         \date Jan 2005
  210.         \brief This passed the triggered() action signal in and back out but with some data, easier than     overriding menu and menu bar classes for now.
  211.      */
  212.     void triggeredToTriggeredData();
  213.     /*!
  214.         \author Craig Bradney
  215.         \date Jan 2005
  216.         \brief This passed the toggled() action signal in and back out but with some data, easier than     overriding menu and menu bar classes for now.
  217.         \param ison true if toggled = on
  218.      */
  219.     void toggledToToggledData(bool ison);
  220. };
  221.  
  222. #endif
  223.